package com.reyco1.medusa.display.control
{
	import flash.events.Event;
	import flash.text.AntiAliasType;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;
	
	public class Label extends TextField
	{		
		public function Label(str:String, font:String = "_sans", point:Number = 12, color:Number = 0x000000, embed:Boolean = false, autoResize:Boolean = true, h:Number = 14, isBold:Boolean = false)
		{
			super();
			
			var format:TextFormat = new TextFormat(font, point, color);
			format.bold = isBold;
			format.kerning = true;
			format.letterSpacing = 1;
			
			defaultTextFormat 	= format;
			height 				= h;
			embedFonts 			= embed;
			selectable 			= false;
			mouseEnabled 		= false;
			multiline 			= false;
			defaultTextFormat 	= format;
			autoSize 			= autoResize ? TextFieldAutoSize.LEFT : TextFieldAutoSize.NONE;
			antiAliasType 		= AntiAliasType.ADVANCED;
			htmlText 			= str;
			
			dispatchEvent(new Event(Event.RESIZE));
		}
		
		public function setFormatProperty(type:String, value:*):void
		{
			var format:TextFormat = defaultTextFormat;
			format[type] = value;
			setTextFormat(format);
			dispatchEvent(new Event("PROPERTY_CHANGE"));
		}
		
		override public function set text(value:String):void
		{
			super.text = value;
			if(autoSize != TextFieldAutoSize.NONE) dispatchEvent(new Event(Event.RESIZE));
		}
		
	}
}